-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#12048] Migrate tests for CalculateUsageStatisticsAction #13247
base: master
Are you sure you want to change the base?
Conversation
Instant endTime = TimeHelper.getInstantNearestHourBefore(Instant.now()); | ||
Instant startTime = endTime.minus(COLLECTION_TIME_PERIOD, ChronoUnit.MINUTES); | ||
UsageStatistics testUsageStatistics; | ||
UsageStatisticsAttributes testUsageStatisticsAttributes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make these attributes private
for consistency
testUsageStatistics = new UsageStatistics( | ||
startTime, | ||
COLLECTION_TIME_PERIOD, | ||
NUMBER_OF_RESPONSES, | ||
NUMBER_OF_COURSES, | ||
NUMBER_OF_STUDENTS, | ||
NUMBER_OF_INSTRUCTORS, | ||
NUMBER_OF_ACCOUNT_REQUESTS, | ||
0, | ||
0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can create a getTypicalUsageStatistics()
method in BaseTestCase.java
with all of these values/attributes over there for extensibility.
testUsageStatisticsAttributes = | ||
UsageStatisticsAttributes.builder(startTime, COLLECTION_TIME_PERIOD) | ||
.withNumResponses(NUMBER_OF_RESPONSES) | ||
.withNumCourses(NUMBER_OF_COURSES) | ||
.withNumStudents(NUMBER_OF_STUDENTS) | ||
.withNumInstructors(NUMBER_OF_INSTRUCTORS) | ||
.withNumAccountRequests(NUMBER_OF_ACCOUNT_REQUESTS) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In UsageStatisticsAttributes.java
, there is a valueOf()
method that takes in a teammates.storage.entity.UsageStatistics
and creates a UsageStatisticsAttributes
with the same attributes. It's quite similar to what we're trying to do here
I think we can create another valueOf
(Overloading) for the SQL version of UsageStatistics
. To resolve the class name conflicts, the new method's parameter type can be teammates.sqlstorage.entity.UsageStatistics
(No need to import). The old method can remain.
@InfinityTwo Let me know what you think about this proposal!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idea is great, but from what I saw the last time, the use of UsageStatisticsAttributes
is only for the old datastore logic. I think once migration is completed, I believe the use for it becomes redundant and it solely uses UsageStatistics
in the action, assuming we remember to change it after migration. Right now, it seems like it just concatenates both values together for the output.
I was thinking we could add a comment to remove it eventually but @jasonqiu212 what do you think? I'm cool with either ways.
Part of #12048
Outline of Solution
Added the unit tests for CalculateUsageStatisticsAction for PostgreSQL.